package easy;

public class Solution_1816 {

    public String truncateSentence(String s, int k) {
        String[] strings = s.split(" ");
        int length = Math.max(k, strings.length);
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < length; i++) {
            if (i > 0) {
                buffer.append(" ");
            }
            buffer.append(strings[i]);
        }
        return buffer.toString();
    }

    public static void main(String[] args) {
        Solution_1816 model = new Solution_1816();
//        System.out.println(Integer.parseInt("002010"));
    }
}
